package com.atguigu.springcloud.Controller;



import com.atguigu.springCloud.entites.ComnonResult;
import com.atguigu.springCloud.entites.Payment;
import com.atguigu.springcloud.service.PsymentSerivct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class PaymentCotroller {

    @Autowired
    public PsymentSerivct psymentSerivct;

    @PostMapping(value = "/save")
    public ComnonResult save(@RequestBody Payment payment){

        int save = psymentSerivct.save(payment);

        if (save > 0){
            return new ComnonResult(200,"插入成功",save);
        }
        return new ComnonResult(500,"插入失败",save);
    }

    @GetMapping(value = "Payment/get/{id}")
    public ComnonResult getPaymentByID(@PathVariable("id") int id){
        Payment paymentByID = psymentSerivct.getPaymentByID(id);
        int s= 10/2;
        if (paymentByID != null ){
            return new ComnonResult(200,"查找成功",paymentByID);
        }
        return new ComnonResult(500,"没有找到",null);
    }

}
